package com.xy.manage.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.manage.dao.TrolepermissionDao;
import com.xy.manage.model.Trolepermission;
import com.xy.manage.service.TrolepermissionService;

@Service
@Transactional
public class TrolepermissionServiceImpl extends BaseServiceImpl<Trolepermission> implements
		TrolepermissionService {
	private TrolepermissionDao trolepermissionDao;

	public TrolepermissionServiceImpl(TrolepermissionDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.trolepermissionDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return trolepermissionDao.checkExist("Trolepermission", paraName, paraValue);
	}

	@Override
	public List<Trolepermission> getTrolepermission(Map<String, Object> map) {
		return trolepermissionDao.getTrolepermission(map);
	}
	@Override
	public Pagination getTrolepermissionByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return trolepermissionDao.getTrolepermissionByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Trolepermission save(Trolepermission trolepermission) {
	//	trolepermission.setModtime(new Date());
		if(trolepermission.getPermid()==null){
			//新增
        	return super.save(trolepermission);
		}else{
			//更新
			Trolepermission trolepermission1=trolepermissionDao.get(trolepermission.getPermid());
			try {
				BeanUtil.copyNotNullProperties(trolepermission1, trolepermission);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(trolepermission1);
		}
	}
}